# Maintainer: Morten Linderud <foxboron@archlinux.org>

pkgname=delve
pkgver=1.20.2
pkgrel=1
pkgdesc="A debugger for the Go programming language."
arch=('loong64' 'x86_64')
url="https://github.com/go-delve/delve"
license=('MIT')
makedepends=('go' 'git')
optdepends=('debuginfod: debuginfod support')
options=(!lto strip)
source=("${pkgname}-${pkgver}.tar.gz::https://github.com/go-delve/delve/archive/v${pkgver}.tar.gz")
sha256sums=('58ad7a7fb42ae2ddd33e7d52dad688b249ca8a358eb73b9e48f91eda79e862a8')

build(){
  cd "${pkgname}-${pkgver}"
  export CGO_CPPFLAGS="${CPPFLAGS}"
  export CGO_CFLAGS="${CFLAGS}"
  export CGO_CXXFLAGS="${CXXFLAGS}"
  export CGO_LDFLAGS="${LDFLAGS}"
  export GOFLAGS="-buildmode=pie -mod=readonly -modcacherw"
  export GOPATH="${srcdir}"
  go build -ldflags='-compressdwarf=false -linkmode=external' ./cmd/dlv
}

package() {
  cd "${pkgname}-${pkgver}"
  install -Dm755 dlv "${pkgdir}/usr/bin/dlv"
  install -Dm644 LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
}
